<?php
class My_View_Helper_Image extends Zend_View_Helper_Abstract
{
    protected static $_view;

    public function image()
    {
        if (!self::$_view) {
            self::$_view = Zend_Layout::getMvcInstance()->getView();
        }
        return $this;
    }

    public function getStatus($status, $title = '', $warning = false)
    {
        if ($warning) {
            $name = 'warning';
        } else {
            $name = $status ? '1' : '0';
        }
        $imageSrc = self::$_view->baseUrl(sprintf('images/%s.png', $name));
        $image = sprintf('<img src="%s" title="%s" alt="" />', $imageSrc, $title);
        return $image;
    }

    public function getMail($status = 0, $title = '')
    {
        $name = $status ? 'mail_sent.gif' : 'mail_forward.png';
        $imageSrc = self::$_view->baseUrl('/images/' . $name);
        $image = sprintf('<img src="%s" title="%s" alt="" />', $imageSrc, $title);
        return $image;
    }

    public function getPdf($title = 'PDF')
    {
        $imageSrc = self::$_view->baseUrl('/images/pdf.gif');
        $image = sprintf('<img src="%s" title="%s" alt="" />', $imageSrc, $title);
        return $image;
    }

    public function getEdit($title = 'Editer')
    {
        $imageSrc = self::$_view->baseUrl('/images/pencil.png');
        $image = sprintf('<img src="%s" title="%s" alt="" />', $imageSrc, $title);
        return $image;
    }

    public function getCalculate($title = 'Caculator')
    {
        $imageSrc = self::$_view->baseUrl('/images/calculator.gif');
        $args = array('src' => $imageSrc, 'title' => $title);
        return $this->getImage($args);
    }

    public function getImage($args = array())
    {
        $baseArgs = array('src' => '', 'title' => '', 'alt' => '');
        $args = array_merge($baseArgs, $args);
        $image = sprintf('<img src="%s" title="%s" alt="%s" />', $args['src'], $args['title'], $args['alt']);
        return $image;
    }
}